home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / SoundViewerThread.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-12-16  |  1.4 KB  |  54 lines

  1. package symantec.itools.multimedia;
  2.  
  3. import java.util.Vector;
  4. import sun.audio.AudioDataStream;
  5. import sun.audio.AudioPlayer;
  6.  
  7. class SoundViewerThread extends Thread {
  8.    private Vector clips;
  9.    private boolean doEnd = false;
  10.    private AudioDataStream curStream;
  11.    private int repeatCt;
  12.    private boolean sync = true;
  13.  
  14.    SoundViewerThread(Vector var1, boolean var2, int var3) {
  15.       this.clips = var1;
  16.       this.sync = var2;
  17.       this.repeatCt = var3;
  18.    }
  19.  
  20.    public void run() {
  21.       while(this.repeatCt == -1 || this.repeatCt-- > 0) {
  22.          int var1 = this.clips.size();
  23.  
  24.          for(int var2 = 0; var2 < var1 && !this.doEnd; ++var2) {
  25.             SoundViewerItem var3 = (SoundViewerItem)this.clips.elementAt(var2);
  26.             this.curStream = new AudioDataStream(var3.data);
  27.             AudioPlayer.player.start(this.curStream);
  28.             if (this.sync) {
  29.                try {
  30.                   Thread.sleep((long)var3.delay);
  31.                } catch (InterruptedException var4) {
  32.                }
  33.             }
  34.          }
  35.  
  36.          this.curStream = null;
  37.       }
  38.  
  39.       this.doEnd = false;
  40.    }
  41.  
  42.    void doSync(boolean var1) {
  43.       this.sync = var1;
  44.    }
  45.  
  46.    void doStop() {
  47.       if (this.curStream != null) {
  48.          AudioPlayer.player.stop(this.curStream);
  49.       }
  50.  
  51.       this.doEnd = true;
  52.    }
  53. }
  54.